package scoresort;

import java.util.*;

public class TestStudentScoreSort {
    public static void main(String[] args) {
        Student stu1 = new Student("小明", "123", 80);
        Student stu2 = new Student("张三", "147", 65);
        Student stu3 = new Student("小红", "111", 75);
        Student stu4 = new Student("李四", "666", 83);
        Student stu5 = new Student("王五", "555", 96);
        List<Student> studentList = new ArrayList<>();
        studentList.add(stu1);
        studentList.add(stu2);
        studentList.add(stu3);
        studentList.add(stu4);
        studentList.add(stu5);
        Collections.sort(studentList, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return (int) (o2.score - o1.score);
            }
        });

        System.out.println("------------学生成绩信息排序--------------");
        for (Student s : studentList) {
            System.out.println(s);

        }
        System.out.println("------------最高分学生信息---------------");
        System.out.println(studentList.get(0));
        System.out.println("------------最低分学生信息---------------");
        System.out.println(studentList.get(studentList.size() - 1));

    }

}
